package test03;

/**
 * @Author lzp
 * @Date 2024-03-20
 */
public class CaiJiThread extends Thread{
    @Override
    public void run() {

        while (true){

            System.out.println("采集数据");
            boolean status = Thread.currentThread().isInterrupted();

            if (status){
                System.out.println("中断");
                break;
            }

            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {

                System.out.println("在睡眠中被中断，实现一些后续处理...");
                //二次中断,让 status 变为真
                Thread.currentThread().interrupt();
            }

        }
    }
}
